﻿Imports System.ComponentModel 'nUEVO

Public Class CTraspaso
    Implements INotifyPropertyChanged 'Nuevo

    Private _intOrigen As Integer
    Private _intDestino As Integer
    Private _strTV As String
    Private _strInstrumento As String
    Private _strSerie As String
    Private _intTitulos As Integer
    Private _blnEsEditableNuevo As Boolean

    Private _columnas(5) As Object

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Private Sub NotificarCambio(propname As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propname))
    End Sub

    Default Property Columnas(ByVal index As Integer) As String
        Get
            Return _columnas(index)
        End Get
        Set(ByVal value As String)

            Try
                Select Case index
                    Case 0
                        Me.Origen = value
                        NotificarCambio("Origen")
                    Case 1
                        Me.Destino = value
                        NotificarCambio("Destino")
                    Case 2
                        Me.TV = value
                        NotificarCambio("TV")
                    Case 3
                        Me.Instrumento = value
                        NotificarCambio("Instrumento")
                    Case 4
                        Me.Serie = value
                        NotificarCambio("Serie")
                    Case 5
                        Me.Titulos = value
                        NotificarCambio("Titulos")

                End Select

            Catch ex As Exception
                Throw ex
            End Try

        End Set
    End Property

    Public Shared Function ValorInicalColumna(ByVal index As Integer) As Object
        Select Case index
            Case 0
                Return 0
            Case 1
                Return 0
            Case 2
                Return 0
            Case 3
                Return "Instrumento"
            Case 4
                Return "Serie"
            Case 5
                Return 0
            Case Else
                Return Nothing
        End Select
    End Function

    Public Sub New()
        _blnEsEditableNuevo = False
    End Sub

    Public Sub New(ByVal O As Integer, ByVal D As Integer, ByVal _TV As Integer, ByVal I As String, ByVal S As String, ByVal T As Integer)
        _intOrigen = O
        _intDestino = D
        _strTV = _TV
        _strInstrumento = I
        _strSerie = S
        _intTitulos = T
        _blnEsEditableNuevo = False

        Columnas(0) = _intOrigen
        Columnas(1) = _intDestino
        Columnas(2) = _strTV
        Columnas(3) = _strInstrumento
        Columnas(4) = _strSerie
        Columnas(5) = _intTitulos
    End Sub

    Public Property EsEditableNuevo As Boolean
        Get
            EsEditableNuevo = Me._blnEsEditableNuevo
        End Get
        Set(value As Boolean)
            Me._blnEsEditableNuevo = value
        End Set
    End Property

    Public Property Origen As Integer
        Get
            Return _intOrigen
        End Get
        Set(value As Integer)
            _intOrigen = value
            _columnas(0) = _intOrigen
            NotificarCambio("Origen")
        End Set
    End Property

    Public Property Destino As Integer
        Get
            Return _intDestino
        End Get
        Set(value As Integer)
            _intDestino = value
            _columnas(1) = _intDestino
            NotificarCambio("Destino")
        End Set
    End Property

    Public Property TV As String
        Get
            Return _strTV
        End Get
        Set(value As String)
            _strTV = value
            _columnas(2) = _strTV
            NotificarCambio("TV")
        End Set
    End Property

    Public Property Instrumento As String
        Get
            Return _strInstrumento
        End Get
        Set(value As String)
            _strInstrumento = value
            _columnas(3) = _strInstrumento
            NotificarCambio("Instrumento")
        End Set
    End Property

    Public Property Serie As String
        Get
            Return _strSerie
        End Get
        Set(value As String)
            _strSerie = value
            _columnas(4) = _strSerie
            NotificarCambio("Serie")
        End Set
    End Property

    Public Property Titulos As Integer
        Get
            Return _intTitulos
        End Get
        Set(value As Integer)
            _intTitulos = value
            _columnas(5) = _intTitulos
            NotificarCambio("Titulos")
        End Set
    End Property
End Class
